package sau.diyizu.media.music;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.format.Formatter;
import android.widget.TextView;

import androidx.annotation.NonNull;

import sau.diyizu.media.R;
import sau.diyizu.media.bean.Music;

/**
 @author JYD
 @version 1.0
 @since 2020/12/16 21:15 */
public class MusicDetailDialog extends Dialog {
    private TextView name_tv;
    private TextView author_tv;
    private TextView duration_tv;
    private TextView memorySize_tv;

    public MusicDetailDialog(@NonNull Context context) {
        super(context, R.style.BaseDialogTheme);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_music_detail);

        name_tv = findViewById(R.id.name_tv);
        author_tv = findViewById(R.id.author_tv);
        duration_tv = findViewById(R.id.duration_tv);
        memorySize_tv = findViewById(R.id.memory_size_tv);
    }

    public void show(Music music) {
        show();
        name_tv.setText(music.name);
        author_tv.setText(music.author);
        duration_tv.setText(music.formatDuration());
        memorySize_tv.setText(Formatter.formatFileSize(getContext(), music.memorySize));
    }
}
